/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Huu Vinh
 */
@Entity
@Table(name = "PaymentDetails", catalog = "Radio_Cabs", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PaymentDetails.findAll", query = "SELECT p FROM PaymentDetails p"),
    @NamedQuery(name = "PaymentDetails.findByAccId", query = "SELECT p FROM PaymentDetails p WHERE p.paymentDetailsPK.accId = :accId"),
    @NamedQuery(name = "PaymentDetails.findByPaymentId", query = "SELECT p FROM PaymentDetails p WHERE p.paymentDetailsPK.paymentId = :paymentId"),
    @NamedQuery(name = "PaymentDetails.findByPaymentDate", query = "SELECT p FROM PaymentDetails p WHERE p.paymentDetailsPK.paymentDate = :paymentDate"),
    @NamedQuery(name = "PaymentDetails.findByAmount", query = "SELECT p FROM PaymentDetails p WHERE p.amount = :amount")})
public class PaymentDetails implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PaymentDetailsPK paymentDetailsPK;
    @Basic(optional = false)
    @Column(name = "Amount", nullable = false)
    private double amount;
    @JoinColumn(name = "PaymentId", referencedColumnName = "PaymentId", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private PaymentRate paymentRate;
    @JoinColumn(name = "AccId", referencedColumnName = "AccId", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Accounts accounts;

    public PaymentDetails() {
    }

    public PaymentDetails(PaymentDetailsPK paymentDetailsPK) {
        this.paymentDetailsPK = paymentDetailsPK;
    }

    public PaymentDetails(PaymentDetailsPK paymentDetailsPK, double amount) {
        this.paymentDetailsPK = paymentDetailsPK;
        this.amount = amount;
    }

    public PaymentDetails(int accId, int paymentId, Date paymentDate) {
        this.paymentDetailsPK = new PaymentDetailsPK(accId, paymentId, paymentDate);
    }

    public PaymentDetailsPK getPaymentDetailsPK() {
        return paymentDetailsPK;
    }

    public void setPaymentDetailsPK(PaymentDetailsPK paymentDetailsPK) {
        this.paymentDetailsPK = paymentDetailsPK;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public PaymentRate getPaymentRate() {
        return paymentRate;
    }

    public void setPaymentRate(PaymentRate paymentRate) {
        this.paymentRate = paymentRate;
    }

    public Accounts getAccounts() {
        return accounts;
    }

    public void setAccounts(Accounts accounts) {
        this.accounts = accounts;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (paymentDetailsPK != null ? paymentDetailsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PaymentDetails)) {
            return false;
        }
        PaymentDetails other = (PaymentDetails) object;
        if ((this.paymentDetailsPK == null && other.paymentDetailsPK != null) || (this.paymentDetailsPK != null && !this.paymentDetailsPK.equals(other.paymentDetailsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.PaymentDetails[ paymentDetailsPK=" + paymentDetailsPK + " ]";
    }
    
}
